/*
*Mount NPC
*By Icecoldcoke  (Hai2u)
*Description - Mounts the player onto various models..
*/

#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305)
#endif

class SCRIPT_DECL MountNPC : public GossipScript
{
    public:
        void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
        void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
        void GossipEnd(Object * pObject, Player* Plr);
        void Destroy()
    {
        delete this;
    }
};

void MountNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
{
    GossipMenu *Menu;
        uint32 TextID = 820;
        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), TextID, Plr);
        Menu->AddItem(0, "Please Dismount Me!", 1);
        Menu->AddItem(0, "100 Gold Mounts (100% speed!)", 2);
        Menu->AddItem(0, "1000 Gold Mounts (200% Speed!)", 3);
        Menu->AddItem(0, "10000 Gold  Mounts!(300% Speed!)", 4); // Was originally going to be flymode but I changed my mind, and i'm not 100% sure on how to anyway.
        
    if(AutoSend)
        Menu->SendTo(Plr);
}

void MountNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
    Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
    if(pCreature==NULL)
        return;

        GossipMenu *Menu;

        switch(IntId)
        {

            case 0:
                {
                    GossipHello(pCreature, Plr, true);
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You have been dismounted." );
                }
                break;

            case 1:
                {
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);
                    Plr->SetPlayerSpeed(RUN, 7);
                    Plr->Gossip_Complete();
                }
                break;
            case 2:
                {
                    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
                    Menu->AddItem(5, "Spectral Gryphon", 5);
                    Menu->AddItem(5, "Amani Lynx", 6);
                    Menu->AddItem(5, "Dragon Hawk", 7);
                    Menu->AddItem(5, "Amani Bear Spirit", 8); // This is kinda gigantic.. removal could be needed
                    Menu->AddItem(0, "1000 Gold Mounts (200% Speed!)", 3);
                    Menu->AddItem(5, "[Back]", 0);
                    Menu->SendTo(Plr);
                }
                break;
        
            case 3:
                {
                    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
                    Menu->AddItem(5,"Amani Lynx Spirit",9); // This is a large model.
                    Menu->AddItem(5,"Elwynn Pink Elekk",10);
                    Menu->AddItem(5,"Panther",11);
                    Menu->AddItem(5, "[Back]", 0);
                    Menu->SendTo(Plr);
                }
                break;
            
            case 4:
                {
                    objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1, Plr);
                    Menu->AddItem(5, "Amani DragonHawk Spirit", 12); // Note Another large model
                    Menu->AddItem(5, "Aether Ray", 13);
                    Menu->AddItem(5, "Onyx Netherwing Drake", 14);
                    Menu->AddItem(5, "[Back]", 0);
                    Menu->SendTo(Plr);
                }
                break;
        

            case 5:
                {
                    uint32 price=1000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 17328); //Sets the mount display ID to a Spectral Gryphon
                    Plr->SetPlayerSpeed(RUN, 14); // 14 is 100% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Spectral Gryphon" );
                        Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                        Plr->Gossip_Complete();
                }
                }
                break;

            case 6:
                {
                    uint32 price=1000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);

                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 19705); //Sets the mount display ID to a Amani Lynx
                    Plr->SetPlayerSpeed(RUN, 14); // 14 is 100% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Lynx" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 7:
                {
                    uint32 price=1000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 17547); //Sets the mount display ID to a Dragon Hawk
                    Plr->SetPlayerSpeed(RUN, 14); // 14 is 100% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Dragon Hawk" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 8:
                {
                    uint32 price=1000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 21830); //Sets the mount display ID to a Amani Bear Spirit
                    Plr->SetPlayerSpeed(RUN, 14); // 14 is 100% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Bear!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 9:
                {
                    uint32 price=10000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 21793); //Sets the mount display ID to a Amani Lynx Spirit
                    Plr->SetPlayerSpeed(RUN, 21); // 21 is 200% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Lynx!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 10:
                {
                    uint32 price=10000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 22732); //Sets the mount display ID
                    Plr->SetPlayerSpeed(RUN, 21); // 21 is 200% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Elekk!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 11:
                {
                    uint32 price=10000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 599); //Sets the mount display ID
                    Plr->SetPlayerSpeed(RUN, 21); // 21 is 200% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Panther!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 12:
                {
                    uint32 price=100000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 21831); //Sets the mount display ID
                    Plr->SetPlayerSpeed(RUN, 28); // 28 is 300% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Dragon Hawk!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 13:
                {
                    uint32 price=100000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 21282); //Sets the mount display ID
                    Plr->SetPlayerSpeed(RUN, 28); // 28 is 300% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Aether Ray!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

            case 14:
                {
                    uint32 price=100000000;
                    uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);
                if (currentgold>=price)
                {
                    int32 newgold = currentgold - price; // Minuses the price from their gold which in this case is 10gold
                    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); // Sets gold to the value after subtraction
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // This will unmount them before mounting them, to avoid possible issues
                    Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 21520); //Sets the mount display ID
                    Plr->SetPlayerSpeed(RUN, 28); // 28 is 300% speed I believe.. makes them go 100% faster
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Have fun on your Onyx Netherwing Drake!" );
                    Plr->Gossip_Complete();
                }
				else
				{
                    pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "You don't have enough money!" );
                    Plr->Gossip_Complete();
                }
                }
                break;

    }
}


void MountNPC::GossipEnd(Object * pObject, Player* Plr)
{
    GossipScript::GossipEnd(pObject, Plr);
}

void SetupMountNPC(ScriptMgr * mgr)
{
    GossipScript * gs = (GossipScript*) new MountNPC();
    mgr->register_gossip_script(690005, gs);
}